<html>
<head><meta charset="utf-8"><title>pin-self · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html">pin-self</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="169074627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169074627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169074627">(Jun 26 2019 at 19:57)</a>:</h4>
<p>So <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>, <span class="user-mention" data-user-id="126931">@centril</span>, <span class="user-mention" data-user-id="119009">@eddyb</span>: I'm trying to do my long-promised write-up for <a href="https://github.com/rust-lang/rust/pull/61207" target="_blank" title="https://github.com/rust-lang/rust/pull/61207">https://github.com/rust-lang/rust/pull/61207</a>. As far as I can tell, our current behavior is pretty conservative -- <a href="https://gist.github.com/nikomatsakis/c5c8e585989924e8485df48ab6bbc3dd" target="_blank" title="https://gist.github.com/nikomatsakis/c5c8e585989924e8485df48ab6bbc3dd">I took some notes here</a>. Is there a particular pattern that <em>works</em> which we are concerned about? I'm going back through our minutes to try and figure that out -- or is the sole concern that things which would be convenient don't work presently?</p>



<a name="169077229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169077229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169077229">(Jun 26 2019 at 20:31)</a>:</h4>
<p>I'll have a look in a bit</p>



<a name="169081856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169081856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169081856">(Jun 26 2019 at 21:27)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> yes, this: <a href="https://github.com/rust-lang/rust/pull/60944#issuecomment-493915865" target="_blank" title="https://github.com/rust-lang/rust/pull/60944#issuecomment-493915865">https://github.com/rust-lang/rust/pull/60944#issuecomment-493915865</a></p>



<a name="169081910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169081910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169081910">(Jun 26 2019 at 21:27)</a>:</h4>
<p>is a thing which <em>does</em> work but I wouldn't expect it to if it doesn't also work for <code>Pin&lt;&amp;mut Self&gt;</code></p>



<a name="169082011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169082011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169082011">(Jun 26 2019 at 21:28)</a>:</h4>
<p>which then caused the whole round of confusion when eddy was suggesting this extension: <a href="https://github.com/rust-lang/rust/pull/60944#issuecomment-494722365" target="_blank" title="https://github.com/rust-lang/rust/pull/60944#issuecomment-494722365">https://github.com/rust-lang/rust/pull/60944#issuecomment-494722365</a></p>



<a name="169091848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169091848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169091848">(Jun 27 2019 at 00:01)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> ok thanks -- although that <em>particular</em> example is unstable.</p>



<a name="169091938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169091938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169091938">(Jun 27 2019 at 00:03)</a>:</h4>
<p>but yes it is behaving oddly</p>



<a name="169092212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169092212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169092212">(Jun 27 2019 at 00:08)</a>:</h4>
<p>ok, I see, but if you use <code>Pin</code>, then it <em>does</em> compile, and that is bad</p>



<a name="169130328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130328">(Jun 27 2019 at 12:40)</a>:</h4>
<p>wanna see something fun? (and I suppose ironic)</p>



<a name="169130339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130339">(Jun 27 2019 at 12:40)</a>:</h4>
<p>I changed the elision rules to only allow literal <code>Self</code> not <code>Foo</code> (assuming a method of <code>impl Foo {...}</code>) to get the special <code>&amp;self</code>-like treatment, and I have only 2 failures in libcore</p>



<a name="169130344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130344">(Jun 27 2019 at 12:40)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L447" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L447">https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L447</a></p>



<a name="169130350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130350">(Jun 27 2019 at 12:40)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L484" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L484">https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L484</a></p>



<a name="169130374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130374">(Jun 27 2019 at 12:41)</a>:</h4>
<p>for some reason all of those methods are written as <code>self: &amp;Pin&lt;T&gt;</code> or <code>self: &amp;mut Pin&lt;T&gt;</code></p>



<a name="169130520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130520">(Jun 27 2019 at 12:43)</a>:</h4>
<p>in <em>the entire codebase</em>, that file has the only examples of <code>&amp;self</code> or <code>&amp;mut self</code> written out like that</p>



<a name="169130584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130584">(Jun 27 2019 at 12:44)</a>:</h4>
<p>it's those 2 plus the <code>set</code> method</p>



<a name="169130718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130718">(Jun 27 2019 at 12:45)</a>:</h4>
<p>and the only <code>self: &amp;(mut )?Self</code> is in <code>core::fmt</code> in a <code>write_fmt</code> method that has <code>mut self: &amp;mut Self</code>, presumably making <code>self</code> point to something else (as <code>mut &amp;mut self</code> is syntactically invalid)</p>



<a name="169130911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169130911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169130911">(Jun 27 2019 at 12:47)</a>:</h4>
<p>tests have a bunch of examples of <code>self: &amp;Foo</code> and <code>self: &amp;mut Bar</code>, of course</p>



<a name="169133592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169133592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169133592">(Jun 27 2019 at 13:18)</a>:</h4>
<p>but only one (run-pass) test seems to fails when I run the tests, anyway</p>



<a name="169133870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169133870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169133870">(Jun 27 2019 at 13:21)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> opened <a href="https://github.com/rust-lang/rust/pull/62181" target="_blank" title="https://github.com/rust-lang/rust/pull/62181">https://github.com/rust-lang/rust/pull/62181</a> for crater purposes</p>



<a name="169159520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169159520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169159520">(Jun 27 2019 at 18:09)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> can you explain why those examples needed to be changed?</p>



<a name="169159537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169159537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169159537">(Jun 27 2019 at 18:09)</a>:</h4>
<p>the elision being used there is "syntactic" in the way I would read it</p>



<a name="169162249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169162249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169162249">(Jun 27 2019 at 18:36)</a>:</h4>
<p>Well it's semantic in the sense that it requires context not provided by the function signature itself</p>



<a name="169162263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169162263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169162263">(Jun 27 2019 at 18:36)</a>:</h4>
<p>to determine whether something is the <code>Self</code> type or not</p>



<a name="169162293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169162293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169162293">(Jun 27 2019 at 18:37)</a>:</h4>
<p>But I can live with that <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="169222475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169222475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169222475">(Jun 28 2019 at 13:03)</a>:</h4>
<p>yeah <span class="user-mention" data-user-id="126931">@centril</span> is right. also, this is just for <span class="user-mention" data-user-id="116009">@nikomatsakis</span>, I doubt we'll actually make a breaking change here</p>



<a name="169222560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169222560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169222560">(Jun 28 2019 at 13:04)</a>:</h4>
<p>like, <span class="user-mention" data-user-id="116009">@nikomatsakis</span> wanted to know what breakage would result if we required writing <code>self: &amp;Self</code> or <code>&amp;self</code> in order to apply the elision special-case</p>



<a name="169497108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/pin-self/near/169497108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/pin-self.html#169497108">(Jul 02 2019 at 16:47)</a>:</h4>
<blockquote>
<p>I doubt we'll actually make a breaking change here</p>
</blockquote>
<p>I am curious -- the current rules are ... pretty ad-hoc, as well, in that they consider "the current struct" (regardless of parameters etc) to be "self enough". But the most I would expect is to deprecate that behavior and encourage manual annotation.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>